; TestController device configuration file for Philips PM2811 Programmable Power Supplies.
; Version 1.0
; Date 04-09-2023
; Written by Gertjan Miedema,  info at miedemageluid dot nl,  Username "Gertjan" at EEVblog.
;
; The device configuration file "R&SHMC8043.txt" by WA and HKJ was used as basis for this file.
;
; For use with TestController, software to control and log data: https://lygte-info.dk/project/TestControllerIntro%20UK.html
; For use with a Prologix GPIB interface, or clone. (AR488!)
; Tested with a AR488 GPIB-USB interface.


; Some tips:
;
; - In the remote mode, pressing the front panel keys will have no effect on programmed settings.
;   However, it is possible to view the actual settings on the front panel display, by pressing these front panel keys:
;   SELECT, V (Vset), I (Iset), OVP, DELAY, UNMASK, DISP, LCL, and AUX.
;
; - The default GPIB address is 28. 
;   One can check and set the GPIB address by pressing the AUX key as many times as necessary to display: ADDRESS  xx.
;
; - It seems strange that when the power supply is in Protection, because of a fault, in the menu the output indicator is still on...
;   This is because output on/off and protection are 2 different mechanisms.
;   When in protection, the output settings are reduced to 0V and 0A, but the output is still on.
;
; - There are also multichannel versions of this power supply: PM2812 and PM2813 (modular, with different channel output options)
;   It should be easy to create a definition for these, based on this definition, and using the 3ch R&S HMC8043 definition as guide.
;   To facilitate this, all Output Channel selection commands are retained in this definition. (Here all CH1, the only Output...)


; Known issues:
;
; - The Fluke versions are all, as far as known, responding to *IDN? with: PHILIPS,PM2811/xx. So this is used for identification.
;   So, if you have a identification problem with a late Fluke PM2811, try changing the #idString to: FLUKE,PM2811/x.
;   If you find a Fluke version who answers *IDN? with "Fluke,...", please let me know!
;
; - There is a bug in the GPIB implementation that HKJ has not fixed yet: It can only handle one device for each GPIB controller.





; Meta definition for Philips PM2811 30V/10A Power Supply
#metadef
#idString PHILIPS,PM2811/0
#name Philips PM2811 30V-10A
#handle PM2811

#replaceText MaxCurrent 10
#replaceText MaxVoltage 30
#replaceText MaxOVP 32



; Meta definition for Fluke PM2811 30V/10A Power Supply
; As far as known all Fluke versions kept "PHILIPS" in de *IDN? answer string
#metadef
#idString PHILIPS,PM2811/0
#name Fluke PM2811 30V-10A
#handle PM2811

#replaceText MaxCurrent 10
#replaceText MaxVoltage 30
#replaceText MaxOVP 32



; Meta definition for Philips PM2811 60V/5A Power Supply
#metadef
#idString PHILIPS,PM2811/1
#name Philips PM2811 60V-5A
#handle PM2811

#replaceText MaxCurrent 5
#replaceText MaxVoltage 60
#replaceText MaxOVP 62



; Meta definition for Fluke PM2811 60V/5A Power Supply
; As far as known all Fluke versions kept "PHILIPS" in de *IDN? answer string
#metadef
#idString PHILIPS,PM2811/1
#name Fluke PM2811 60V-5A
#handle PM2811

#replaceText MaxCurrent 5
#replaceText MaxVoltage 60
#replaceText MaxOVP 62




#meta
#idString PHILIPS,PM2811
#name Philips PM2811
#handle PM2811
#port GPIB

; Start up delay, only needed for AR488 with slow booting Chinese Nano clones
#resetDelay 3.5

; The author statement is used for the listing in the About window.
#author Gertjan Miedema


#notes  Device configuration file for Fluke / Philips PM2811 Programmable Power Supplies.

 - For use with a Prologix GPIB interface, or clone (AR488!).

 - The default GPIB address is 28. 
   One can check and set the GPIB address by pressing the AUX key as many times as necessary to display: ADDRESS xx.

 - In Remote mode, settings can still be read out on the display, using the front pannel buttons. (But not changed...)

 - For more info, tips and known issues, see the notes in the header of the device configuration file (Philips PM2811.txt)


Device configuration file version: 1.0




;---------  Read out commands  ---------

; A list of possible column name with unit and formatter (SI, Time, Int, D0..D6)
#value CH1_A A D3
#value CH1_V V D2
#value CH1_W W D3



; Prepare the meter to response to #askValues
; #prepareSample



; How to poll for data, this is used for table and #values?
; a #askMode, #cmdMode and #prepareSample is used before this is string is used.
; This is a single line command
; INST:NSEL 1  NumberSELect, Select output channel nr. 1
; MEAS:CURR?   MEASure CURRrent (of previously selected channel)
; MEAS:VOLT?   MEASure VOLTage (of previously selected channel)
; MEAS:POW?    MEASure POWer (of previously selected channel)

#askValues INST:NSEL 1;MEAS:CURR?;MEAS:VOLT?;MEAS:POW?





;---------  Emergency all outputs Off command  ---------

; INST:NSEL 1  Select output channel nr. 1 (NumberSELect)
; OUTP 0       Switch output OFF
#outputOff INST:NSEL 1;OUTP 0




;------------------  Initial commands & Final commands  --------------

; *RST         Reset to default settings (see Reference Manual p1-52)
; [500]        Pause, 500 miliseconds
; INST:NSEL 1  INSTrument:Select Output Channel 1
; INST:STAT 1  INSTrument:STATe 1 = Place instrument in OPERATE mode (out of Standby)
; ABOR         ABORt, stops the execution of the step function
; *CLS         CLear Status, forces the device into the "operation complete idle" state
; [LOC]        Set device in local control mode (GPIB buss command)

#initCmd [500];*RST;[1000];INST:NSEL 1;INST:STAT 1
#finalCmd ABOR;*CLS;*RST;[1000];[LOC];[500];



#interfaceType PS
#interface setVoltage INST:NSEL (channel);VOLT (value)
#interface setCurrent INST:NSEL (channel);CURR (value)
#interface setOn INST:NSEL (channel);OUTP (value)

#interface getVoltage INST:NSEL (channel);VOLT?
#interface getCurrent INST:NSEL (channel);CURR?
#interface getOn INST:NSEL (channel);OUTP?

#interface readCurrent 0
#interface readVoltage 1
#interface readPower 2
 



;=====================   Mode (Function) menu   ==================

#cmdSetup radio Voltage
:read: INST:NSEL 1;VOLT?
:write: INST:NSEL 1;VOLT #
:update: Current, Protection_Status, Mode_of_Operation
:updatedelayed: 0.3
:tip: Quick Set Output voltage
5V 5.0
9V 9.0
12V 12.0
13.8V 13.8
24V 24.0
30V 30.0


#cmdSetup number Voltage
:read: INST:NSEL 1;VOLT?
:write: INST:NSEL 1;VOLT
:update: Current, Protection_Status, Mode_of_Operation
:updatedelayed: 0.3
:tip: Set Output Voltage
Volt 0 MaxVoltage



#cmdSetup radio Current
:read: INST:NSEL 1;CURR?
:write: INST:NSEL 1;CURR #
:update: Voltage, Protection_Status, Mode_of_Operation
:updatedelayed: 0.3
:tip: Quick Set Maximum Output Current
100mA 0.1
200mA 0.2
500mA 0.5
1A 1.0
2A 2.0
5A 5.0


#cmdSetup number Current
:read: INST:NSEL 1;CURR?
:write: INST:NSEL 1;CURR
:update: Voltage, Protection_Status, Mode_of_Operation
:updatedelayed: 0.3
:tip: Set Maximum Output Current
Amps 0 MaxCurrent


#cmdSetup checkbox U_&_I_set_Coupling
:read: INST:NSEL 1;CURR:AUTO?
:write: INST:NSEL 1;CURR:AUTO
:string:
:readmath: replace(value,0,"OFF")
:readmath: replace(value,1,"ON")
:update: Voltage, Current, Protection_Status, Mode_of_Operation
:updatedelayed: 0.3
:tip: Coupling of Voltage and Current settings for Max 60W output
On_(Max_60W_out) OFF ON


#cmdSetup indicator Mode_of_Operation
:read: INST:NSEL 1;SOUR:FUNC:MODE?
Constant_Voltage value=="VOLT" green
Constant_Current value=="CURR" (255,204,51)


#cmdSetup buttonsOn Output
:read: INST:NSEL 1;OUTP?
:write: INST:NSEL 1;OUTP #
:update: Protection_Status, Mode_of_Operation
:updatedelayed: 0.3
:tip: Turn output ON or OFF
:color: (0,153,0)
:updatealloff:
Off 0
On 1


;------------  Protection menu settings  ------------

#cmdSetup separator Over_Voltage_Protection
2 100 Raised

#cmdSetup number Over_Voltage_Protection
:read: INST:NSEL 1;VOLT:PROT?
:write: INST:NSEL 1;VOLT:PROT
:update: Protection_Status, Mode_of_Operation
:updatedelayed: 0.3
:tip: Set the Over Voltage Protection level
Volt 2 MaxOVP


#cmdSetup checkbox Over_Current_Protection
:read: INST:NSEL 1;CURR:PROT:STAT?
:write: INST:NSEL 1;CURR:PROT:STAT
:update: Protection_Status, Mode_of_Operation
:updatedelayed: 0.3
:tip: <html>Switch the OCP protection ON or OFF.  Action when Set Current threshold is reached with OCP OFF:<br>Current will be limited to Set Current (CC mode), OCP ON: Current will be reduced to zero (output OFF)
On 0 1


#cmdSetup indicatornum Over_Current_Protection
:read: INST:NSEL 1;CURR:PROT:STAT?
:write: INST:NSEL 1;CURR:PROT:STAT
CC_Limit_mode 0 (255,204,51)
Output_OFF_mode 1 red


; Alternative protection status indicator (without detailed info)
; #cmdSetup indicatornum Protection_Status
; :read: INST:NSEL 1;OUTP:PROT:TRIP?
; All_OK 0 green
; TRIPPED! 1 red

#cmdSetup indicatornum Protection_Status
:read: STAT:QUES:INST:ISUM1:COND?
All_OK 0 green
Over_Voltage 1 red
Over_Curent 2 red
Over_Temp_or_Sense 16 red
CAL_invalid 256 red


#cmdSetup button Reset_Protection
:write: INST:NSEL 1;OUTP:PROT:CLE
:tip: Reset current active protection (OCP, OVP, Thermal, open Sense)
:update: Protection_Status, Mode_of_Operation
:updatedelayed: 0.3


